<template>
  <el-dialog
    title="生成短链接"
    v-model="visible"
    width="500px"
  >
    <!-- ... 其他代码 ... -->
    
    <div class="result-row" v-if="shortUrl">
      <div class="label">短链接:</div>
      <div class="content">
        <el-input
          v-model="shortUrl"
          readonly
        >
          <template #append>
            <el-button @click="copyUrl(shortUrl)">复制</el-button>
          </template>
        </el-input>
      </div>
    </div>

    <div class="result-row" v-if="adminUrl">
      <div class="label">管理链接:</div>
      <div class="content">
        <el-input
          v-model="adminUrl" 
          readonly
        >
          <template #append>
            <el-button @click="copyUrl(adminUrl)">复制</el-button>
          </template>
        </el-input>
      </div>
    </div>

    <!-- ... 其他代码 ... -->
  </el-dialog>
</template>

<script setup>
import { ref, computed } from 'vue'
import { ElMessage } from 'element-plus'

// ... 其他代码 ...

const shortUrl = computed(() => {
  if (!form.value.shortCode) return ''
  return `${import.meta.env.VITE_BASE_URL}/s/${form.value.shortCode}`
})

const adminUrl = computed(() => {
  if (!form.value.shortCode) return ''
  // 直接使用完整的管理URL,不需要拼接本地域名
  return `${import.meta.env.VITE_BASE_URL}/d/admin/${form.value.shortCode}`
})

const copyUrl = async (url) => {
  try {
    await navigator.clipboard.writeText(url)
    ElMessage.success('复制成功')
  } catch (err) {
    ElMessage.error('复制失败')
  }
}

// ... 其他代码 ...
</script> 